﻿Imports DataAccess
Imports Entities
Public Class ProveedorBL
    Public Shared Function List() As List(Of PROVEEDORES)
        Dim lista As New List(Of PROVEEDORES)
        lista = ProveedorDAL.List
        Return lista
    End Function
    Public Shared Function save(ByVal zObject As PROVEEDORES) As PROVEEDORES
        If ProveedorDAL.Exist(zObject.PROVEEDOR) Then
            Return ProveedorDAL.Update(zObject)
        Else
            Return ProveedorDAL.Create(zObject)
        End If
    End Function
    Public Shared Function Delete(ByVal zId As Long) As Boolean
        Return ProveedorDAL.Delete(zId)
    End Function
    Public Shared Function SearchByRut(ByVal zRut As String) As PROVEEDORES
        Return ProveedorDAL.SearchByRut(zRut)
    End Function
    Public Shared Function SearchById(ByVal zId As Long) As PROVEEDORES
        Return ProveedorDAL.SearchById(zId)
    End Function
    Public Shared Function GetNombre(ByVal zId As Long) As String
        Dim obj As New PROVEEDORES
        obj = ProveedorDAL.SearchById(zId)
        If Not IsNothing(obj) Then
            Return obj.NOMBRE
        Else
            Return ""
        End If
    End Function
End Class
